package com.infoland.afanmall.model.guiGe.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.CacheKit;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.model.guiGe.entity.GuiGeEntity;
import com.infoland.afanmall.model.guiGe.linster.CartGuiGeLinster;
import com.infoland.afanmall.base.util.layoutManager.GridSpacingItemDecoration;

import java.util.List;

/****中间的Recl数据适配器*/
public class GuiGeAdapter1 extends BaseQuickAdapter<GuiGeEntity, BaseViewHolder> {
    private GuiGeAdapter2 guige_adapter;
    private RecyclerView recyclerView;
    private CartGuiGeLinster cartGuiGeLinster;
    private String now_gui_ge;

    public GuiGeAdapter1(int item_cart, List<GuiGeEntity> guiGeEntities, String now_gui_ge) {
        super(R.layout.cart_item, guiGeEntities);
        this.now_gui_ge = now_gui_ge;
    }

    @Override
    protected void convert(BaseViewHolder helper, GuiGeEntity item) {
//        LogKit.E("GuiGeAdapter1 ---->   ", "  GuiGeAdapter1");
        List<GuiGeEntity.GoodsSpecValListBean> goodsSpecValList = item.getGoodsSpecValList();
        helper.setText(R.id.item_cart_guige, item.getS_name());
        recyclerView = helper.getView(R.id.item_cart_recl);
//        在外层数据源 （三个checkbox）
        guige_adapter = new GuiGeAdapter2(R.layout.item_cart_guige_cart, goodsSpecValList, now_gui_ge);
        recyclerView.setLayoutManager(new GridLayoutManager(CacheKit.APP_CONTEXT, 3));
        recyclerView.addItemDecoration(new GridSpacingItemDecoration(3, 20, true));
        recyclerView.setAdapter(guige_adapter);
        guige_adapter.setLinster((item1, position) -> {
            cartGuiGeLinster.goo(item1, position);
        });
    }

    public void setGuiGeLinster(CartGuiGeLinster cartGuiGeLinster) {
        this.cartGuiGeLinster = cartGuiGeLinster;
    }
}
